package com.star.mentor.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.star.mentor.dto.EvaluationItemScoreDTO;
import com.star.mentor.entity.MentorEvaluationScore;
import com.star.mentor.mapper.MentorEvaluationScoreMapper;
import com.star.mentor.service.MentorEvaluationScoreService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 导师评估项目分数 服务实现类
 *
 * @author yangzj
 */
@Service
public class MentorEvaluationScoreServiceImpl extends ServiceImpl<MentorEvaluationScoreMapper, MentorEvaluationScore> implements MentorEvaluationScoreService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void saveBatch(List<EvaluationItemScoreDTO> items, Long mentorEvaluationId) {
        List<MentorEvaluationScore> collect = items.stream().map(c -> new MentorEvaluationScore().setMentorEvaluationId(mentorEvaluationId)
                .setItemId(c.getItemId()).setScore(c.getScore())).collect(Collectors.toList());
        this.saveBatch(collect);
    }
}
